package 其他;

/*
 * 设商店里面共有n个人进去买东西，他们的付款时间为：到达前台排队的时间 + 付款操作时间；
 * 求出所有顾客付款需要的时间。
 * 例如：输入：
 *      3
 *      1 2
 *      2 5
 *      4 3
 *      输出：
 *          15
 */
import java.util.ArrayList;
import java.util.Scanner;

public class test06 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int people = sc.nextInt();
        int sum = 0;
        ArrayList<Integer> arriveTime = new ArrayList<>();  //顾客到达前台的时间
        ArrayList<Integer> payDuration = new ArrayList<>(); //顾客付款操作的时间
        ArrayList<Integer> list3 = new ArrayList<>();       //每个顾客付款总时间
        for (int i = 0; i < people; i++) {
            arriveTime.add(i,sc.nextInt());
            payDuration.add(i,sc.nextInt());
        }
        list3.add(0,payDuration.get(0));
        int t = arriveTime.get(0) + payDuration.get(0);
        for (int i = 1; i < people; i++) {
            if(t >= arriveTime.get(i)) {
                list3.add(i, payDuration.get(i) + (t - arriveTime.get(i)));
                t = t + payDuration.get(i);
            }
            else{
                list3.add(i,payDuration.get(i));
                t = arriveTime.get(i) + payDuration.get(i);
            }
        }
        for (int i = 0; i < list3.size(); i++) {
            sum += list3.get(i);
        }
        System.out.println("总顾客付款时间：" + sum);
    }
}
